<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">


    <title>任务分配管理</title>
    <meta name="keywords" content="">
    <meta name="description" content="">

    <link rel="shortcut icon" href="favicon.ico"> 
    <link href="${ctx!}/assets/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="${ctx!}/assets/css/font-awesome.css?v=4.4.0" rel="stylesheet">
    
    <link href="${ctx!}/assets/css/plugins/bootstrap-editable/bootstrap-editable.css" rel="stylesheet"/>
    
    <link href="${ctx!}/assets/css/plugins/bootstrap-editable/bootstrap-editable.css" rel="stylesheet"/>
     
    <link href="${ctx!}/assets/css/plugins/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">

    <link href="${ctx!}/assets/css/animate.css" rel="stylesheet">
    <link href="${ctx!}/assets/css/style.css?v=4.1.0" rel="stylesheet">


</head>

<body class="gray-bg">
    <div class="wrapper wrapper-content  animated fadeInRight">
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox ">
                    <div class="ibox-title">
                        <h5>任务分配管理</h5>
                    </div>
                    <div class="ibox-content"> 
                        <hr>
                        <div class="row row-lg">
		                    <div class="col-sm-12">
		                        <!-- Example Card View -->
		                        <div class="example-wrap">
		                            <div class="example">
		                            	<table id="table_list"></table>
		                            </div>
		                        </div>
		                        <!-- End Example Card View -->
		                    </div>
	                    </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!-- 全局js -->
    <script src="${ctx!}/assets/js/jquery.min.js?v=2.1.4"></script>
    <script src="${ctx!}/assets/js/bootstrap.min.js?v=3.3.6"></script>
    
	<!-- Bootstrap table -->
    <script src="${ctx!}/assets/js/plugins/bootstrap-table/bootstrap-table.min.js"></script>
    <script src="${ctx!}/assets/js/plugins/bootstrap-table/bootstrap-table-mobile.min.js"></script>
    <script src="${ctx!}/assets/js/plugins/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>
    <script src="${ctx!}/assets/js/plugins/bootstrap-editable/bootstrap-editable.min.js"></script>
    <!-- Peity -->
    <script src="${ctx!}/assets/js/plugins/peity/jquery.peity.min.js"></script>

    <script src="${ctx!}/assets/js/plugins/layer/layer.min.js"></script>

    <!-- 自定义js -->
    <script src="${ctx!}/assets/js/content.js?v=1.0.0"></script>

    <!-- Page-Level Scripts -->
    <script>
        $(document).ready(function () {
        	//初始化表格,动态从服务器加载数据  
			$("#table_list").bootstrapTable({
			    //使用get请求到服务器获取数据  
			    method: "POST",
			    //必须设置，不然request.getParameter获取不到请求参数
			    contentType: "application/x-www-form-urlencoded",
			    //获取数据的Servlet地址  
			    url: "${ctx!}/admin/user/assign/list",
			    //表格显示条纹  
			    striped: true,
			    //启动分页  
			    pagination: true,
			    //每页显示的记录数  
			    pageSize: 10,
			    //当前第几页  
			    pageNumber: 1,
			    //记录数可选列表  
			    pageList: [5, 10, 15, 20, 25],
			    //是否启用查询  
			    search: false,
			    //是否启用详细信息视图
			    detailView:false,
			    //表示服务端请求  
			    sidePagination: "server",
			    //设置为undefined可以获取pageNumber，pageSize，searchText，sortName，sortOrder  
			    //设置为limit可以获取limit, offset, search, sort, order  
			    queryParamsType: "undefined",
			    //json数据解析
			    responseHandler: function(res) {
			        return {
			            "rows": res.content,
			            "total": res.totalElements
			        };
			    },
			    //数据列
			    columns: [{
			        title: "ID",
			        field: "userId"
			    },{
			        title: "用户名",
			        field: "userName"
			    },{
			        title: "分配类型",
			        field: "assignType",
			        formatter: function(value,row,index){
			        	if (value == '1') 
                        	return '<span class="label label-primary">全部分配</span>';
                        if (value == '2')
                             return '<span class="label label-danger">仅图片</span>';
                        if (value == '3')
                             return '<span class="label label-danger">仅视频</span>';
			        }
			    },{
			        title: "操作",
			         field: "assignId",
			         formatter: function(value,row,index){ 
			            var operateHtml = null;
			            if(row.assignType==1 || row.assignType==null){
			              operateHtml = '<select class="selectpicker" onchange="selectOnchang(this,'+row.assignId+','+row.userId+')" ><option value="1"  selected="selected" >全部分配</option><option  value="2">分配图片</option><option value="3">分配视频</option> </select>';
			            }else if(row.assignType==2){
			            operateHtml = '<select class="selectpicker" onchange="selectOnchang(this,'+row.assignId+','+row.userId+')" ><option value="1"  >全部分配</option><option value="2" selected="selected">分配图片</option><option value="3">分配视频</option> </select>';
			            }else if(row.assignType==3){
			            operateHtml = '<select class="selectpicker" onchange="selectOnchang(this,'+row.assignId+','+row.userId+')" ><option value="1"  >全部分配</option><option value="2">分配图片</option><option value="3" selected="selected">分配视频</option> </select>';
			            }
			             
			        	return operateHtml; 
			        }
			    }]  
			 
             });
         });
         
         
         function selectOnchang(obj,id,userId){
             var value =  obj.options[obj.selectedIndex].value;
             var obj = {
                    assignId : id,
                    userId : userId,
                    assignType :value
                }
        	layer.confirm('确定修改吗?', {icon: 3, title:'提示'}, function(index){
        		$.ajax({
    	    		   type: "POST",
    	    		   dataType: "json",
    	    		   url: "${ctx!}/admin/user/assign/update",
    	    		   headers: { 'Content-type': 'application/json;charset=UTF-8' },
	                   method: 'POST',
	                   data:  JSON.stringify(obj),
	                   dataType: "json",
    	    		   success: function(msg){
	 	   	    			layer.msg(msg.message, {time: 2000},function(){
	 	   	    				$('#table_list').bootstrapTable("refresh");
	 	   	    				layer.close(index);
	 	   					});
    	    		   }
    	    	});
       		}); 
         }
         
    </script>


    
    
    

</body>

</html>
